<template>
    <div class="production-create-template">
        <el-button class="return" type="text" @click="jumpToDefault"><i class="fa fa-angle-left mr5"></i>返回</el-button>
        <h4 class="header">创建产品信息</h4>
        <div class="content">
            <div class="filter-section">
                <span class="fl title">产品基本信息</span>
                <span class="fr gray">注：带有*为必填项</span>
            </div>
            <div class="product-form">
                <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px">
                    <el-form-item label="产品名称" prop="productName">
                        <el-input v-model="ruleForm.productName" size="mini"></el-input>
                    </el-form-item>
                    <el-form-item label="机构名称" prop="instituName">
                        <el-input v-model="ruleForm.insitituName" size="mini"></el-input>
                    </el-form-item>
                    <el-form-item label="产品类别" prop="productType">
                        <el-checkbox-group v-model="ruleForm.productType">
                            <el-checkbox label="全部" name="type"></el-checkbox>
                            <el-checkbox label="网站专区" name="type"></el-checkbox>
                            <el-checkbox label="手机APP" name="type"></el-checkbox>
                            <el-checkbox label="微刊" name="type"></el-checkbox>
                            <el-checkbox label="触摸屏" name="type"></el-checkbox>
                        </el-checkbox-group>
                    </el-form-item>
                    <el-form-item label="产品状态" prop="productStatus">
                        <el-select v-model="ruleForm.productStatus" size="mini">
                            <el-option label="区域一" value="shanghai"></el-option>
                            <el-option label="区域二" value="beijing"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="使用状态" prop="useStatus">
                        <el-select v-model="ruleForm.useStatus" size="mini">
                            <el-option label="区域一" value="shanghai"></el-option>
                            <el-option label="区域二" value="beijing"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="经办人" prop="operator">
                        <el-input v-model="ruleForm.operator" size="mini"></el-input>
                    </el-form-item>
                    <el-form-item label="联系人" prop="contact">
                        <el-input v-model="ruleForm.contact" size="mini"></el-input>
                    </el-form-item>
                    <el-form-item label="合同编号" prop="contractNumber">
                        <el-input v-model="ruleForm.contractNumber" size="mini"></el-input>
                    </el-form-item>
                </el-form>
            </div>
            <div class="filter-section">
                <span class="fl title">专区产品相关信息</span>
            </div>
            <div class="product-form">
                <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="135px">
                    <el-form-item label="专区资源类型" prop="ZQType">
                        <el-checkbox-group v-model="ruleForm.ZQType">
                            <el-checkbox label="期刊" name="type"></el-checkbox>
                            <el-checkbox label="报志" name="type"></el-checkbox>
                            <el-checkbox label="图书" name="type"></el-checkbox>
                        </el-checkbox-group>
                    </el-form-item>
                    <el-form-item label="专区服务方式" prop="ZQMode">
                        <el-checkbox-group v-model="ruleForm.ZQMode">
                            <el-checkbox label="定制开发专区" name="type"></el-checkbox>
                            <el-checkbox label="博看专区" name="type"></el-checkbox>
                        </el-checkbox-group>
                    </el-form-item>
                    <el-form-item label="专区开通账号数量" prop="ZQNumber">
                        <el-input v-model="ruleForm.ZQNumber" size="mini"></el-input>
                        个
                    </el-form-item>
                    <el-form-item label="开通日期" prop="openDate">
                        <el-input v-model="ruleForm.openDate" size="mini"></el-input>
                    </el-form-item>
                    <el-form-item label="IP段" prop="IP">
                        <el-input v-model="ruleForm.IP" size="mini"></el-input>
                    </el-form-item>
                    <el-form-item label="并发数" prop="conNumber">
                        <el-input v-model="ruleForm.conNumber" size="mini"></el-input>
                    </el-form-item>
                    <el-form-item label="前台用户名/密码" prop="BUP">
                        <el-input v-model="ruleForm.BUP" size="mini"></el-input>
                    </el-form-item>
                    <el-form-item label="专区地址" prop="address">
                        <el-input v-model="ruleForm.address" size="mini"></el-input>
                    </el-form-item>
                    <el-form-item label="后台连接" prop="connect">
                        <el-input v-model="ruleForm.connect" size="mini"></el-input>
                    </el-form-item>
                    <el-form-item label="后台用户名/密码" prop="AUP">
                        <el-input v-model="ruleForm.AUP" size="mini"></el-input>
                    </el-form-item>
                    <el-form-item label="通知状态" prop="notiState">
                        <el-select v-model="ruleForm.notiState" size="mini">
                            <el-option label="区域一" value="shanghai"></el-option>
                            <el-option label="区域二" value="beijing"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="通知时间" prop="notiTime">
                        <el-input v-model="ruleForm.notiTime" size="mini"></el-input>
                    </el-form-item>
                    <el-form-item label="通知地址" prop="notiAddress">
                        <el-input v-model="ruleForm.notiAddress" size="mini"></el-input>
                    </el-form-item>
                    <el-form-item label="截图" prop="screenshot">
                        <el-upload
                                class="upload-file"
                                action="https://jsonplaceholder.typicode.com/posts/"
                                :on-preview="handlePreview"
                                :on-remove="handleRemove"
                                :before-remove="beforeRemove"
                                multiple
                                :limit="1"
                                :file-list="ruleForm.screenshot">
                            <el-button size="mini" type="primary">上传图片</el-button>
                            <div slot="tip" class="el-upload__tip fr">图片格式：JPG或PNG，文件大小不超过2M</div>
                        </el-upload>
                    </el-form-item>
                    <el-form-item label="产品保质期" prop="productShelf" class="simple-fl">
                        <el-input v-model="ruleForm.productShelf" size="mini"></el-input>
                        年
                    </el-form-item>
                    <el-form-item label="备注" prop="ZQNote" class="form-textarea">
                        <el-input type="textarea" v-model="ruleForm.ZQNote" size="mini"></el-input>
                    </el-form-item>
                </el-form>
            </div>
            <div class="filter-section">
                <span class="fl title">APP产品相关信息</span>
            </div>
            <div class="product-form">
                <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="125px">
                    <el-form-item label="APP资源类型" prop="APPType">
                        <el-checkbox-group v-model="ruleForm.APPType">
                            <el-checkbox label="期刊" name="type"></el-checkbox>
                            <el-checkbox label="报志" name="type"></el-checkbox>
                            <el-checkbox label="图书" name="type"></el-checkbox>
                        </el-checkbox-group>
                    </el-form-item>
                    <el-form-item label="APP服务方式" prop="APPMode">
                        <el-checkbox-group v-model="ruleForm.APPMode">
                            <el-checkbox label="定制开发专区" name="type"></el-checkbox>
                            <el-checkbox label="博看专区" name="type"></el-checkbox>
                        </el-checkbox-group>
                    </el-form-item>
                    <el-form-item label="APP开通账号数量" prop="APPNumber" class="simple-fl">
                        <el-input v-model="ruleForm.APPNumber" size="mini"></el-input>
                        个
                    </el-form-item>
                    <el-form-item label="备注" prop="APPNote" class="form-textarea">
                        <el-input type="textarea" v-model="ruleForm.APPNote" size="mini"></el-input>
                    </el-form-item>
                </el-form>
            </div>
            <div class="filter-section">
                <span class="fl title">微刊产品相关信息</span>
            </div>
            <div class="product-form">
                <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px">
                    <el-form-item label="微刊资源类型" prop="WKType">
                        <el-checkbox-group v-model="ruleForm.WKType">
                            <el-checkbox label="期刊" name="type"></el-checkbox>
                            <el-checkbox label="报志" name="type"></el-checkbox>
                            <el-checkbox label="图书" name="type"></el-checkbox>
                        </el-checkbox-group>
                    </el-form-item>
                    <el-form-item label="微刊服务方式" prop="WKMode">
                        <el-checkbox-group v-model="ruleForm.WKMode">
                            <el-checkbox label="微信API接口对接" name="type"></el-checkbox>
                            <el-checkbox label="微信公众号授权" name="type"></el-checkbox>
                        </el-checkbox-group>
                    </el-form-item>
                    <el-form-item label="微刊运营方式" prop="WKOperate">
                        <el-checkbox-group v-model="ruleForm.WKOperate">
                            <el-checkbox label="博看代运营" name="type"></el-checkbox>
                            <el-checkbox label="客户自运营" name="type"></el-checkbox>
                        </el-checkbox-group>
                    </el-form-item>
                    <el-form-item label="微刊账号" prop="WKNumber">
                        <el-input v-model="ruleForm.WKNumber" size="mini"></el-input>
                    </el-form-item>
                    <el-form-item label="微刊密码" prop="WKPassword" class="simple-fl">
                        <el-input v-model="ruleForm.WKPassword" size="mini"></el-input>
                    </el-form-item>
                    <el-form-item label="微刊地址" prop="WKAddress" class="form-textarea">
                        <el-input v-model="ruleForm.WKAddress" size="mini"></el-input>
                    </el-form-item>
                    <el-form-item label="备注" prop="WKNote" class="form-textarea">
                        <el-input type="textarea" v-model="ruleForm.WKNote" size="mini"></el-input>
                    </el-form-item>
                </el-form>
            </div>
            <div class="filter-section">
                <span class="fl title">触摸屏产品相关信息</span>
            </div>
            <div class="product-form">
                <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="120px">
                    <el-form-item label="触摸屏资源类型" prop="CMPType">
                        <el-checkbox-group v-model="ruleForm.CMPType">
                            <el-checkbox label="期刊" name="type"></el-checkbox>
                            <el-checkbox label="报志" name="type"></el-checkbox>
                            <el-checkbox label="图书" name="type"></el-checkbox>
                        </el-checkbox-group>
                    </el-form-item>
                    <el-form-item label="触摸屏资源范围" prop="CMPRange">
                        <el-checkbox-group v-model="ruleForm.CMPRange">
                            <el-checkbox label="全库" name="type"></el-checkbox>
                            <el-checkbox label="选库" name="type"></el-checkbox>
                            <el-checkbox label="选刊" name="type"></el-checkbox>
                        </el-checkbox-group>
                    </el-form-item>
                    <el-form-item label="触摸屏数量" prop="CMPCount">
                        <el-input v-model="ruleForm.CMPCount" size="mini"></el-input>
                        个
                    </el-form-item>
                    <el-form-item label="触摸屏服务方式" prop="CMPMode">
                        <el-checkbox-group v-model="ruleForm.CMPMode">
                            <el-checkbox label="镜像" name="type"></el-checkbox>
                            <el-checkbox label="远程" name="type"></el-checkbox>
                            <el-checkbox label="馆外用户名" name="type"></el-checkbox>
                        </el-checkbox-group>
                    </el-form-item>
                    <el-form-item label="备注" prop="CMPNote" class="form-textarea">
                        <el-input type="textarea" v-model="ruleForm.CMPNote" size="mini"></el-input>
                    </el-form-item>
                </el-form>
            </div>
        </div>
        <div class="btn-wrap">
            <el-button type="primary" @click="submitForm('ruleForm')">确定</el-button>
            <el-button @click="cancelForm()">取消</el-button>
        </div>
    </div>
</template>

<script>
    export default {
        name: "ProductionCreate",
        data() {
            return {
                ruleForm: {
                    productName: "",
                    instituName: "",
                    productType: [],
                    productStatus: "",
                    useStatus: "",
                    operator: "",
                    contact: "",
                    contractNumber: "",
                    ZQType: [],
                    ZQMode: [],
                    ZQNumber: "",
                    openDate: "",
                    IP: "",
                    conNumber: "",
                    BUP: "",
                    address: "",
                    connect: "",
                    AUP: "",
                    notiState: "",
                    notiTime: "",
                    notiAddress: "",
                    screenshot: [],
                    productShelf: "",
                    ZQNote: "",
                    APPType: [],
                    APPMode: [],
                    APPNumber: "",
                    APPNote: "",
                    WKType: [],
                    WKMode: [],
                    WKOperate: [],
                    WKNumber: "",
                    WKPassword: "",
                    WKAddress: "",
                    WKNote: "",
                    CMPType: [],
                    CMPRange: [],
                    CMPCount: "",
                    CMPMode: [],
                    CMPNote: "",
                },
                rules: {
                    productName: [
                        {required: true, message: '请输入产品名称', trigger: 'blur'}
                    ],
                    instituName: [
                        {required: true, message: '请输入机构名称', trigger: 'blur'}
                    ],
                    productType: [
                        {required: true, message: '请选择产品类别', trigger: 'change'},
                    ],
                    productStatus: [
                        {required: true, message: '请选择产品状态', trigger: 'change'},
                    ],
                    useStatus: [
                        {required: true, message: '请选择使用状态', trigger: 'change'},
                    ],
                    operator: [
                        {required: true, message: '请输入经办人', trigger: 'blur'}
                    ],
                    contact: [
                        {required: true, message: '请输入联系人', trigger: 'blur'}
                    ],
                    contractNumber: [
                        {required: true, message: '请输入合同编号', trigger: 'blur'}
                    ],
                    ZQType: [
                        {required: true, message: '请选择专区资源类型', trigger: 'change'},
                    ],
                    ZQMode: [
                        {required: true, message: '请选择专区服务方式', trigger: 'change'},
                    ],
                    ZQNumber: [
                        {required: true, message: '请输入专区开通账号数量', trigger: 'blur'}
                    ],
                    openDate: [
                        {required: true, message: '请输入开通日期', trigger: 'blur'}
                    ],
                    BUP: [
                        {required: true, message: '请输入前台用户名/密码', trigger: 'blur'}
                    ],
                    address: [
                        {required: true, message: '请输入专区地址', trigger: 'blur'}
                    ],
                    connect: [
                        {required: true, message: '请输入后台连接', trigger: 'blur'}
                    ],
                    AUP: [
                        {required: true, message: '请输入后台用户名/密码', trigger: 'blur'}
                    ],
                    notiState: [
                        {required: true, message: '请输入通知状态', trigger: 'blur'}
                    ],
                    notiTime: [
                        {required: true, message: '请输入通知时间', trigger: 'blur'}
                    ],
                }
            }
        },
        methods: {
            handleRemove(file, fileList) {
                console.log(file, fileList);
            },
            handlePreview(file) {
                console.log(file);
            },
            beforeRemove(file, fileList) {
                return this.$confirm(`确定移除 ${file.name}？`);
            },
            submitForm(formName) {
                this.$refs[formName].validate((valid) => {
                    if (valid) {
                        console.log('submit!');
                        this.jumpToDefault();
                    } else {
                        console.log('error submit!!');
                        return false;
                    }
                });
            },
            cancelForm() {
                this.jumpToDefault();
            },
            jumpToDefault() {
                this.$parent.curPath = 'default';
            }
        }
    }
</script>

<style lang="scss">
    @import "src/common/common.style";
    .production-create-template {
        background-color: #ffffff;
        width: 100%;
        height: 100%;
        position: relative;
        .return {
            position: absolute;
            top: 0;
            left: 15px;
            padding: 0;
        }
        .header {
            text-align: center;
        }
        .content {
            height: 85%;
            @include ofy-a();
            .filter-section {
                clear: both;
                border-bottom: 1px solid #ddd;
                padding-bottom: 25px;
                margin: 0 10px;
                padding-left: 5px;
                padding-right: 5px;
                .title {
                    font-size: $font-mn;
                    font-weight: 600;
                }
                .gray {
                    color: gray;
                }
            }
            .product-form {
                padding-top: 10px;
                .el-form {
                    margin: 0 50px;
                    .el-form-item:not(.form-textarea) {
                        margin-bottom: 15px;
                        display: inline-block;
                        width: 50%;
                        .el-form-item__content {
                            @include fl();
                            margin-left: 0 !important;
                        }
                        .el-input {
                            width: 300px;
                        }
                    }
                    .el-upload__tip {
                        margin-top: 0;
                        padding-left: 5px;
                        color: #cccccc;
                    }
                    .simple-fl {
                        @include fl();
                    }
                    .form-textarea {
                        clear: both;
                        .el-textarea, .el-input__inner {
                            width: 80%;
                            float: left;
                            .el-textarea__inner {
                                min-height: 100px !important;
                            }
                        }
                    }
                }
            }
        }
        .btn-wrap {
            .el-button {
                width: 100px;
                margin: 0 50px;
            }
        }
    }
</style>